import * as service from '../services/global';

export default {
  namespace: 'global',
  state: {
    data: null,
  },
  reducers: {
    save(state, { payload: { data }}) {
      return { ...state, data };
    }
  },
  effects: {
    *fetch({ payload: { value }}, {call, put}) {
      const result = yield call(service.getAll, value);
      yield put({
        type: 'save',
        payload: {
          data: result.data,
        }
      })
    }
  },
}
